﻿// Utilities/FileHelper.cs

using System;
using System.IO;

namespace DatabaseManager.Utilities
{
    public static class FileHelper
    {
        /// <summary>
        /// 确保路径存在
        /// </summary>
        public static void EnsureDirectoryExists(string path)
        {
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
        }

        /// <summary>
        /// 写入文本到文件
        /// </summary>
        public static void WriteToFile(string filePath, string content)
        {
            File.WriteAllText(filePath, content);
        }

        /// <summary>
        /// 读取文件内容
        /// </summary>
        public static string ReadFromFile(string filePath)
        {
            return File.Exists(filePath) ? File.ReadAllText(filePath) : null;
        }
    }
}